
package br.ufscar.sor.ppgccs.educatransito.entidade;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Joaquim
 */
@Entity
@Table(name = "itemquestao")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Itemquestao.findAll", query = "SELECT i FROM Itemquestao i"),
    @NamedQuery(name = "Itemquestao.findByIditemQuestao", query = "SELECT i FROM Itemquestao i WHERE i.iditemQuestao = :iditemQuestao"),
    @NamedQuery(name = "Itemquestao.findByCorreta", query = "SELECT i FROM Itemquestao i WHERE i.correta = :correta")})
public class Itemquestao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "iditemQuestao")
    private Integer iditemQuestao;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "alternativa")
    private String alternativa;
    @Basic(optional = false)
    @NotNull
    @Column(name = "correta")
    private boolean correta;
    @JoinColumn(name = "idQuestoes", referencedColumnName = "idQuestoes")
    @ManyToOne(optional = false)
    private Questoes idQuestoes;

    public Itemquestao() {
    }

    public Itemquestao(Integer iditemQuestao) {
        this.iditemQuestao = iditemQuestao;
    }

    public Itemquestao(Integer iditemQuestao, String alternativa, boolean correta) {
        this.iditemQuestao = iditemQuestao;
        this.alternativa = alternativa;
        this.correta = correta;
    }

    public Integer getIditemQuestao() {
        return iditemQuestao;
    }

    public void setIditemQuestao(Integer iditemQuestao) {
        this.iditemQuestao = iditemQuestao;
    }

    public String getAlternativa() {
        return alternativa;
    }

    public void setAlternativa(String alternativa) {
        this.alternativa = alternativa;
    }

    public boolean getCorreta() {
        return correta;
    }

    public void setCorreta(boolean correta) {
        this.correta = correta;
    }

    public Questoes getIdQuestoes() {
        return idQuestoes;
    }

    public void setIdQuestoes(Questoes idQuestoes) {
        this.idQuestoes = idQuestoes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iditemQuestao != null ? iditemQuestao.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Itemquestao)) {
            return false;
        }
        Itemquestao other = (Itemquestao) object;
        if ((this.iditemQuestao == null && other.iditemQuestao != null) || (this.iditemQuestao != null && !this.iditemQuestao.equals(other.iditemQuestao))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.alternativa;
    }
    
}
